<?php
if(isset($_SESSION['valor']) && $_SESSION['valor'] && isset($_SESSION['rol']) && isset ($_SESSION["login"]) ){				
	class UsuariosController extends StandardForm {

		public $scaffold = true;

		//public $template = "menu_admin";
	
		/*public function before_filter(){
			
			$login= Session::get_data('login');
			$password= Session::get_data('password');
			
			$db = DbBase::raw_connect();
			$db->query("select * from usuarios where login='$login' and password='$password'");
			
			
			
			if($db->num_rows()!=0){
		
			return $this->route_to("controller:plandepago ","action: menu_admin");
			
			 } 
			 else {	Flash::error("Usted est&aacute; intentando acceder al sistema de manera incorrecta.");
			return $this->route_to("controller:login ","action: index");
			 
			 
			 }
		
			 $db->close();	
			
		}*/
		/*
		public function registrar(){
			$this->route_to("controller: login");
		
		} */
		
		public function before_insert(){
		
		$this->Usuarios->password=sha1($this->request("fl_login"));
		/*
		$login= Session::get_data('login');
			$password= Session::get_data('password');
			
			$db = DbBase::raw_connect();
			$db->query("select * from usuarios where login='$login' and password='$password' and rol='A'");
			
			
			
			if($db->num_rows()!=0){
		
			//$this->route_to("action: construct");
			
			 } else {Flash::error("Usted est&aacute; intentando acceder al sistema de manera incorrecta.");
			$this->delete();
	
	
	
	
	
			}
			
			$db->close();
		
		*/
		}
		
		/*function index(){
			
			$login= Session::get_data('login');
			$password= Session::get_data('password');
			
			$db = DbBase::raw_connect();
			$db->query("select * from usuarios where login='$login' and password='$password'");
			
			
			
			if($db->num_rows()!=0){
		
			$this->route_to("action: construct");
			
			 } else {Flash::error("Usted est&aacute; intentando acceder al sistema de manera incorrecta.");
			
	
	
	
	
	
			}
			
			$db->close();

		}*/
		
		
		public function before_query(){
			/*
			$login= Session::get_data('login');
			$password= Session::get_data('password');
			
			$db = DbBase::raw_connect();
			$db->query("select * from usuarios where login='$login' and password='$password' and rol='A'");
			
			
			
			if($db->num_rows()!=0){
		
			$this->route_to("action: query");
			
			 } else {Flash::error("Usted est&aacute; intentando acceder al sistema de manera incorrecta.");
			
	
	
	
	
	
			}
			
			$db->close();
		
			*/
			
		}
		
		public function __construct(){
			//$this->unable_query();
			$this->unable_browse();
			$this->unable_report();
			
			// echo "<form action=\"plandepago/menu_admin" .  "\" method=\"POST\">\n\n"; 



   //echo "<input type='submit' name='submit' value='Volver'>";
			$this->set_caption("nombre", "Nombre y Apellido");
			$this->set_hidden("password");
		$this->set_combo_static("rol",array(
			array("A","ADMINISTRADOR"),
			array("G","GERENTE"),
			array("F","ADMINISTRATIVO"),
			array("I","VENDEDOR INTERIOR"),
			array("V","VENDEDOR")
			));
		

			
			
		}
		/*public function before_filter(){
			$login= Session::get_data('login');
			$password= Session::get_data('password');
			
			$db = DbBase::raw_connect();
			$db->query("select * from usuarios where login='$login' and password='$password'");
			
			
			
			if($db->num_rows()!=0){
		
			 $this->route_to("controller: plandepago","action:menu_admin");
			
			 } else return 'error';
			
			
        
      }*/

		
		public function cambio_clave(){
			
			
		
		}
		
		public function cambio(){
			
			
			
		
		}
		
		public function redireccionar(){
			$this->route_to("controller: plandepago");
		
		}
		
	}
}else{ echo("<script>parent.location.href = '/www.oscardiaz.com.ar/index.php?s=n';</script>");}	
?>
